package com.aabte.spring.dao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.Random;
import java.util.UUID;

/**
 * @author Daniel
 */
@Repository
public class UserDao {

    public static final String INSERT_SQL = "INSERT INTO `tbl_user`(username, age) VALUES(?, ?)";

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void insert(){
        String username = UUID.randomUUID().toString().replace("-", "");
        jdbcTemplate.update(INSERT_SQL, username, new Random().nextInt(100));
    }

}

